<!--
    action确认框
    先查询check_path，如果返回结果为true，弹框确认，确认后查询on_ok_path；
    否则不弹框直接查询on_ok_path
-->
<script>
import base from '../actionBase'
import $ from "@/common"
export default {
    name: 'action_confirm',
    extends: base,
    data() {
      return {
        title: '操作确认',
        content: '确定要这么做吗？',
      };
    },
    methods: {
      actionTrigger() {
        let checkPath = this.actionModel.param.check_path
        let onOkPath = this.actionModel.param.on_ok_path
        $.link(checkPath, this.actionData).then(res => {
          let result = res.data.result
          if (result) {
            let content = res.data.content
            this.$Modal.confirm({
              title: this.title,
              content: content || this.content,
              onOk: () => {
                $.link(onOkPath, this.actionData).finally(() => {
                  this.$owner.update()
                })
              }
            });
          } else {
            $.link(onOkPath, this.actionData).finally(() => {
              this.$owner.update()
            })
          }
				}).catch((error) => {
					console.error(error)
				});
      }
    },
    created() {}
}
</script>
